/**
 * memberPaymentOrdersServiceImpl
 * 项目名称:分秒金融
 *
 * @author lunli
 *
 * 功能描述:代付订单管理
 * 
 * 历史版本:2017-07-03 v1.0.0 lunli  创建:
 * 
 */
package com.fmjr.member.memberPaymentOrders.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

import java.util.List;

import com.fmjr.common.util.SqlUtil;
import com.fmjr.common.base.exception.BusinessException;
import com.fmjr.common.base.util.Pager;
import com.fmjr.member.memberPaymentOrders.bean.MemberPaymentOrders;
import com.fmjr.member.memberPaymentOrders.dao.MemberPaymentOrdersDao;
import com.fmjr.member.memberPaymentOrders.service.IMemberPaymentOrdersService;


@Service("memberPaymentOrdersService")
public class  MemberPaymentOrdersServiceImpl implements IMemberPaymentOrdersService {
	

	@Autowired
    private MemberPaymentOrdersDao memberPaymentOrdersDao;

	/**
	 * 根据条件查询代付订单记录
	 * @author lunli
	 * @param  pager
	 * @return MemberPaymentOrdersList
	 * @throws BusinessException
	 */
	public void selectMemberPaymentOrdersList(Pager<MemberPaymentOrders> pager) throws BusinessException{
		int totalCount = memberPaymentOrdersDao.selectMemberPaymentOrdersCount(pager);
		int numPerPage = SqlUtil.checkPageSize(pager.getNumPerPage());
		int currentPage = SqlUtil.checkPageCurrent(totalCount, numPerPage, pager.getPageNum());
		pager.setLimitStart(SqlUtil.countOffset(currentPage, numPerPage));
		pager.setPageSize(numPerPage);
		pager.setCurrentPage(currentPage);
		pager.setTotalCount(totalCount);
		pager.setTotalPage(totalCount%numPerPage==0?totalCount/numPerPage:totalCount/numPerPage+1);
		List<MemberPaymentOrders> list = memberPaymentOrdersDao.selectMemberPaymentOrdersList(pager);
		pager.setList(list);
	}
	
	/**
	 * 根据ID查询代付订单记录
	 * @author lunli
	 * @param id
	 * @return domain
	 * @throws BusinessException
	 */
	public MemberPaymentOrders selectMemberPaymentOrdersById(Long id) throws BusinessException{
		return memberPaymentOrdersDao.selectMemberPaymentOrdersById(id);
	}

	/**
	 *  删除代付订单记录
	 * @author lunli	 
	 * @param id
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int deleteMemberPaymentOrdersById(Long id) throws BusinessException{
		return memberPaymentOrdersDao.deleteMemberPaymentOrdersById(id);
	}
	
	/**
	 * 修改代付订单记录
	 * @author lunli
	 * @param memberPaymentOrders
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int updateMemberPaymentOrders(MemberPaymentOrders memberPaymentOrders) throws BusinessException{
		return memberPaymentOrdersDao.updateMemberPaymentOrdersSelective(memberPaymentOrders);
	}

	/**
	 * 新增代付订单记录
	 * @author lunli
	 * @param memberPaymentOrders
	 * @return
	 * @throws BusinessException
	 */
	@Transactional(rollbackFor=BusinessException.class)
	public int createMemberPaymentOrders(MemberPaymentOrders memberPaymentOrders) throws BusinessException{
		return memberPaymentOrdersDao.createMemberPaymentOrders(memberPaymentOrders);
	}
	

	

}
